<?php
class Users_model extends MY_Model{
	var $name;
	var $pass;
	var $permission;
	
	function __construct($id=''){
		parent::__construct();
		$GLOBALS['table'] = 'users';
		if($id){
			$query	= $this->db->get_where('users',array('id' => $id),1);
			$result	= $query->result();
			if (!empty($result)){
				$this->id = $result[0]->id;
				$this->name	= $result[0]->name;
				$this->pass = $result[0]->pass;
				$this->permission = $result[0]->permission;
			}
		}		
	}
	
	function check_user($name,$pass){
		$query = $this->db->get_where('users',array('name'=>$name),1);
		if($res = $query->row_array()){
			if($res['pass'] == $pass){
				return $res;
			}
			return false;
		}
		return false;
	}
}